import * as types from "./mutation-types";
import Api from "api/api";
const state = {
  buttonList: {},
  buttonEdit: ""
};

const getters = {
  buttonList: state => state.buttonList,
  buttonEdit: state => state.buttonEdit
};

const actions = {
  //按钮列表
  listButtonUsingPOSTS({ commit }, param) {
    return Api.getWorkflowButtonPageList(param).then(ret => {
      commit(types.UPDATE_BUTTON_LIST_LIST, ret.data);
      return ret;
    });
  },
  //按钮新增修改
  buttonEditUsingPOSTS({ commit }, param) {
    return Api.addOrUpdateWorkflowButton(param).then(ret => {
      commit(types.UPDATE_BUTTON_EDIT_LIST, ret.data);
      return ret;
    });
  },
  //按钮删除
  buttonDelUsingPOSTS({ commit }, param) {
    return Api.deleteWorkflowButtonById(param).then(ret => {
      return ret;
    });
  }
};
const mutations = {
  [types.UPDATE_BUTTON_LIST_LIST](state, payload) {
    state.buttonList = payload;
  },
  [types.UPDATE_BUTTON_EDIT_LIST](state, payload) {
    state.buttonEdit = payload;
  }
};

export default {
  state,
  getters,
  actions,
  mutations
};
